#pragma once

#define MAX_TEXT_SIZE	64
#define PSI	1
#define SI	2

class CTreeNode
{
public:
	CTreeNode(void);
	~CTreeNode(void);
	CTreeNode(LPCTSTR lpszText);
	CTreeNode(DWORD parameter, DWORD parameterEx);
private:
	TCHAR* m_szText;
	CTreeNode* m_pChild;
	CTreeNode* m_pBrother;
	void* m_handle;
	BYTE m_type;
	DWORD m_parameter;
	DWORD m_parameterEx;
	USHORT m_nCount;
//operation
public:
	CTreeNode* GetChild(void);
	CTreeNode* GetNextBrother(void);
	BOOL AddChild(CTreeNode* pNode);
	BOOL AddBrother(CTreeNode* pNode);
	BOOL SetItemText(LPCTSTR lpszText);
	LPCTSTR GetItemText(void);
	BOOL SetItemType(BYTE type);
	BYTE GetItemType(void);
	BOOL SetItemData(DWORD parameter);
	DWORD GetItemData(void);
	BOOL SetItemDataEx(DWORD parameterEx);
	DWORD GetItemDataEx(void);
	BOOL SetItemHandle(void* handle);
	void* GetItemHandle(void);
	USHORT ChildCounter(void);
	BOOL operator == (const CTreeNode& Node)const;
};

BOOL TreeInitial(CTreeCtrl* pTree);
BOOL TreeTerm(void);
CTreeNode* GetRootNode(void);
BOOL AddTreeNode(CTreeNode* pNode, CTreeNode* pParent = NULL, CTreeNode* pInsertAfter = NULL);
CTreeNode* GetTreeNode(BYTE type, DWORD parameter, DWORD parameterEx);
CTreeNode* GetParentNode(CTreeNode* pNode);
CTreeNode* GetInsertAfter(CTreeNode* pNode);